{
LANG : PASCAL
PROB : milk
}

program MILK;
const
  fi = 'milk.in';
  fo = 'milk.out';
  max = 5000;
var
  p, a : array[1..max] of longint;
  n, m, res : longint;

procedure inp;
var
  i : longint;
begin
  read(n, m);
  for i := 1 to m do read(p[i], a[i]);
end;

procedure swap(i, j : longint);
var
  temp : longint;
begin
  temp := p[i];
  p[i] := p[j];
  p[j] := temp;
  temp := a[i];
  a[i] := a[j];
  a[j] := temp;
end;

procedure sort(l, r : longint);
var
  i, j, k : longint;
begin
  if l >= r then exit;
  i := l;
  j := r;
  k := p[l + random(r-l+1)];
  repeat
    while p[i] < k do inc(i);
    while p[j] > k do dec(j);
    if i <= j then
    begin
      swap(i, j);
      inc(i); dec(j);
    end;
  until i > j;
  sort(i, r); sort(l, j);
end;

function min(x, y : longint) : longint;
begin
  if x < y then min := x
  else min := y;
end;

procedure process;
var
  i, s, t : longint;
begin
  sort(1, m);
  s := 0;
  res := 0;
  for i := 1 to m do
  begin
    t := min(n-s, a[i]);
    s := s + t;
    res := res + t*p[i];
  end;
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  process;
  writeln(res);
  close(output);
  close(input);
end.